package leetcode.code0014;

public class Solution extends Solution0014 {

	@Override
	public String longestCommonPrefix(String[] strs) {
		String ans = strs[0];
		for (int i = 1; i < strs.length; i++) {
			int p = 0;
			StringBuffer sb = new StringBuffer();
			while (p < ans.length() && p < strs[i].length()) {
				if (ans.charAt(p) == strs[i].charAt(p)) {
					sb.append(ans.charAt(p));
					p++;
				} else {
					break;
				}
			}
			ans = sb.toString();
		}
		return ans;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();

	}

}
